package com.esp.app.bluetooth;

import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.util.Log;

public class BluetoothModel
{
	
	
	private static final String TAG = BluetoothModel.class.getName();

	public static Boolean getBluetoothState(final Context context) 
	{
		BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
		int state = adapter.getState();
		final Boolean bluetoothState;
		switch (state) {
        case BluetoothAdapter.STATE_OFF:
            bluetoothState = false;
            break;
        case BluetoothAdapter.STATE_ON:
            bluetoothState = true;
            break;
        default:
            bluetoothState = false;
        }
		Log.v(TAG,"getBluetoothState()" + bluetoothState);
		return bluetoothState;
	}

	public static void setBluetoothState(final Context context) 
	{
		BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
		int state = adapter.getState();
		if (state == BluetoothAdapter.STATE_OFF) {
			adapter.enable();
		} else if (state == BluetoothAdapter.STATE_ON) {
			adapter.disable();
		}
	}
	
}
